package com.eqdd.yiqidian.ui.discover.workdiary;

import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;

import com.eqdd.annotation.datasave.DealCodeClass;
import com.eqdd.yiqidian.annotation.DealCode;
import com.eqdd.yiqidian.base.CodeRule;
import com.eqdd.yiqidian.http.HttpConfig;
import com.eqdd.yiqidian.rxbus2.Subscribe;
import com.eqdd.yiqidian.rxbus2.ThreadMode;
import com.eqdd.yiqidian.utils.ClickUtil;
import com.lzy.okgo.model.HttpParams;

/**
 * Created by jhj on 18-7-13.
 */
@DealCode(codes = {CodeRule.DIARY_PUBLISH})
public class MyWorkDiaryActivity extends BaseWorkDiaryActivity {


    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        isRxbus = true;
        isDealCode = true;
        super.onCreate(savedInstanceState);

    }

    @Subscribe(codes = {CodeRule.DIARY_PUBLISH}, threadMode = ThreadMode.MAIN)
    public void refreshPublish() {

    }

    @DealCodeClass(classes = {DiaryMsgListActivity.class})
    public void updateWorkDiary(int num) {
        if (num == 0) {
            dataBinding.btNewMsg.setVisibility(View.GONE);
        } else {
            dataBinding.btNewMsg.setVisibility(View.VISIBLE);
            dataBinding.btNewMsg.setTextColor(Color.WHITE);
            dataBinding.btNewMsg.setText(num + "条未读消息");
        }
    }

    @Override
    public void setView() {
        super.setView();
        slimAdapterEx.addHeader(dataBinding.rlHeadRoot);
        ClickUtil.click(dataBinding.btNewMsg, () -> {
            dataBinding.btNewMsg.setVisibility(View.GONE);
            startActivity(DiaryMsgListActivity.class);
        });
    }

    @Override
    String title() {
        return "我的日志";
    }

    @Override
    String getUrl() {
        return HttpConfig.BASE_URL + HttpConfig.DIARY_OF_MY;
    }

    @Override
    HttpParams getParams() {
        return null;
    }

    @Override
    protected void lastRun() {
        super.lastRun();
        ((MyWorkDiaryActivity$$DealCodeInjector) register).update1();
    }
}
